package com.k7.mobile.platform.dataobject;

import java.util.Date;

import com.k7.mobile.platform.web.support.Constants;

public class UserDO extends BaseDO {
	
	private static final long serialVersionUID = -5867186698297780738L;
	
	private Long userId;		//用户id
	private String userNick;	//用户昵称
	
	private Integer adminRole;	//是否为管理员0-否、1-是
	
	private Integer status;	//状态0：正常 1：黑名单
	
	private Date gmtCreate;	//创建时间
	private Date gmtModified;	//修改时间
	private Date forbidBeginTime;	//禁言开始时间
	private Date forbidEndTime;		//禁言结束时间
	
	public Long getUserId() {
		return userId;
	}
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public String getUserNick() {
		return userNick;
	}
	public void setUserNick(String userNick) {
		this.userNick = userNick;
	}
	
	public Integer getAdminRole() {
		return adminRole;
	}
	public void setAdminRole(Integer adminRole) {
		this.adminRole = adminRole;
	}
	
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public String getAdminRoleStr(){
		if(Constants.USER_ADMIN_ROLE_NORMAL.intValue() == this.adminRole)
			return "普通用户";
		if(Constants.USER_ADMIN_ROLE_MANAGER.intValue() == this.adminRole)
			return "管理员";
		
		return "";
	}
	
	public String getStatusStr(){
		if(Constants.USER_STATUS_NORMAL.intValue() == this.status)
			return "正常";
		if(Constants.USER_STATUS_BLACK.intValue() == this.status)
			return "黑名单";
		
		return "";
	}
	
	/**
	 * 判断是否禁言
	 * @return
	 */
	public boolean isForbid(){
		if(this.forbidBeginTime == null || this.forbidEndTime == null)
			return false;
		if(this.forbidBeginTime == null && this.forbidEndTime != null && this.forbidEndTime.getTime() >= new Date().getTime())
			return true;
		if(this.forbidBeginTime != null && this.forbidEndTime == null && this.forbidBeginTime.getTime() <= new Date().getTime())
			return true;
		if(this.forbidBeginTime.getTime() <= new Date().getTime() && this.forbidEndTime.getTime() >= new Date().getTime())
			return true;
		
		return false;
	}
	
	public Date getForbidBeginTime() {
		return forbidBeginTime;
	}
	public void setForbidBeginTime(Date forbidBeginTime) {
		this.forbidBeginTime = forbidBeginTime;
	}
	public Date getForbidEndTime() {
		return forbidEndTime;
	}
	public void setForbidEndTime(Date forbidEndTime) {
		this.forbidEndTime = forbidEndTime;
	}
	public Date getGmtCreate() {
		return gmtCreate;
	}
	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
	}
	public Date getGmtModified() {
		return gmtModified;
	}
	public void setGmtModified(Date gmtModified) {
		this.gmtModified = gmtModified;
	}
	@Override
	public String genCacheKey() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
